#include "dominion.h"
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>

int testVillage()
{
	printf("TESTING Village.\n");
	
	// initializations
	struct gameState *G = newGame();
	struct gameState *G2 = (struct gameState*)malloc(sizeof(struct gameState));

	srand(time(NULL));
	int r = rand();

	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	initializeGame(2, k, r, G);

	// make sure we are setup in a phase and right player to play
	// with the correct card
	
	G->whoseTurn = 0;
	G->numActions = 1;
	G->hand[0][0] = village;

	// copy G to G2 for s2s comparison
	memcpy(G2, G, sizeof(struct gameState));

	printf("Testing if playCard throws an error trying to play.\n");
	assert(playCard(0, 0, 0, 0, G) == 0);
	printf("Test Passed.\n");

	printf("Testing if we gained 1 card.\n");
	assert(G2->handCount[0] == G->handCount[0]);
	printf("Test Passed.\n");

	printf("Testing if we gained +2 actions.\n");
	assert(G2->numActions == G->numActions - 1);
	printf("Test Passed.\n");
	printf("All tests passed.\n");
	return 0;
}

int main() 
{
	return testVillage();
}
